<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/common_tag.jsp"%>
<!-- 应用上下文 -->
<html>
  <head>
  <%@include file="/common/common_js.jsp"%>
  <script type="text/javascript">
	$(function() {
		tree = $('#tt1').tree( {
			url : 'tree_data.json',
			onClick : function(node) {
				var url;
				if (node.attributes.url) {
					url = '${ctx}'+node.attributes.url;
					
				} else {
					url = '${ctx}/common/error.jsp';
				}
				addTab({
					title : node.text,
					closable : true,
					iconCls : node.iconCls,
					href : url
				})
				
			}
		});
		tree2 = $('#tt').tree( {
			onClick : function(node) {
				var url;
				if (node.attributes.url) {
					url = '${ctx}'+node.attributes.url;
					
				} else {
					url = '${ctx}/common/error.jsp';
				}
				addTab({
					title : node.text,
					closable : true,
					iconCls : node.iconCls,
					href : url
				})
				
			}
		});
	});

	function collapseAll() {
		var node = tree.tree('getSelected');
		if (node) {
			tree.tree('collapseAll', node.target);
		} else {
			tree.tree('collapseAll');
		}
	}
	function expandAll() {
		var node = tree.tree('getSelected');
		if (node) {
			tree.tree('expandAll', node.target);
		} else {
			tree.tree('expandAll');
		}
	}
	function changeTheme(theme){
		var link = $("#easyuiThemes");
		link.attr('href', '${ctx}/script/easyui/themes/'+theme+'/easyui.css');
		var $iframe = $('iframe');
		if ($iframe.length > 0) {
			for ( var i = 0; i < $iframe.length; i++) {
				var ifr = $iframe[i];
				$(ifr).contents().find('#easyuiThemes').attr('href', '${ctx}/script/easyui/themes/'+theme+'/easyui.css');
			}
		}
	}
	 function addTab(opts){
			var tt = $('#tabs-content');
			if (tt.tabs('exists', opts.title)){//如果tab已经存在,则选中并刷新该tab    	
		        tt.tabs('select', opts.title);
		        refreshTab(opts);
			} else {
			    	//var content = '<iframe scrolling="no" frameborder="0"  src="'+href+'" style="width:100%;height:100%;"></iframe>';
		    		//t.tabs('add', opts);
		    		tt.tabs('add',opts);
		    	
			}
		}
	/**    
	 * 刷新tab
	 * @cfg 
	 *example: {tabTitle:'tabTitle',url:'refreshUrl'}
	 *如果tabTitle为空，则默认刷新当前选中的tab
	 *如果url为空，则默认以原来的url进行reload
	 */
	function refreshTab(cfg){
		var refresh_tab = cfg.tabTitle?$('#tabs-content').tabs('getTab',cfg.tabTitle):$('#tabs-content').tabs('getSelected');
		if(refresh_tab && refresh_tab.find('iframe').length > 0){
		var _refresh_ifram = refresh_tab.find('iframe')[0];
		var refresh_url = cfg.url?cfg.url:_refresh_ifram.src;
		//_refresh_ifram.src = refresh_url;
		_refresh_ifram.contentWindow.location.href=refresh_url;
		}
	}
	function openWindow(title,url,width,height){
		$('#dialogWindowIframe')[0].src=url;  
		$('#dialogWindow').window({
			title: title,
			width: width||500,
			height: height||400,
			collapsible:false,
			minimizable:false,
			maximizable:false,
			modal: true,
			shadow: true
		});
		$('#dialogWindow').window('open');
	}
	function closeWindow(){
		$('#dialogWindow').window('close');
	}
	function dialogSave(){
		dialogWindowIframe.window.btn_save();
	}
	function dialogClose(){
		$('#dialogWindowIframe')[0].src="";  
		$('#dialogWindow').dialog('close');
	}
	function dialogCloseInfo(infoType,info){
		dialogClose();
		$.messager.alert('提示',info,infoType);
	}
	function loginout(){
		window.location.href  = '${ctx}/shirologin!loginOut.do'
	}
</script>
	</head>
	<body class="easyui-layout">
		<div region="north" split="true" style="height: 70px; padding: 10px;">
			<div style="position: absolute; right: 0px; bottom: 0px;">
				<a href="javascript:void(0);" class="easyui-menubutton"
					menu="#layout_north_kzmbMenu" iconCls="icon-help">控制面板</a><a
					href="javascript:void(0);" class="easyui-menubutton"
					menu="#layout_north_zxMenu" iconCls="icon-back">注销</a>
			</div>
			<div id="layout_north_kzmbMenu" style="width: 100px; display: none;">
				<div onclick="userInfo();">
					个人信息
				</div>
				<div class="menu-sep"></div>
				<div>
					<span>更换主题</span>
					<div style="width: 100px;">
						<div onclick="changeTheme('default');">
							default
						</div>
						<div onclick="changeTheme('black');">
							black
						</div>
						<div onclick="changeTheme('bootstrap');">
							bootstrap
						</div>
						<div onclick="changeTheme('gray');">
							gray
						</div>
						<div onclick="changeTheme('metro');">
							metro
						</div>
					</div>
				</div>
			</div>
			<div id="layout_north_zxMenu" style="width: 100px; display: none;">
				<div onclick="loginAndRegDialog.dialog('open');">
					锁定窗口
				</div>
				<div class="menu-sep"></div>
				<div onclick="loginout()">
					退出系统
				</div>
			</div>
		</div>
		<div region="south" split="true" style="height: 50px; padding: 10px;">
		</div>
		<div region="west" split="true" title="目录"
			style="width: 220px; padding1: 1px; overflow: hidden;" >
			<div class="easyui-accordion" fit="true" border="false">
				<div title="业务导航" style="overflow: auto;" >
				<div region="north" border="false" style="overflow: hidden;">
					<a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-redo" onclick="expandAll();">展开</a><a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-undo" onclick="collapseAll();">折叠</a><a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-reload" onclick="tree.tree('reload');">刷新</a>
					<div style="border-bottom:black 1px solid;" ></div>
				</div>
					<ul id="tt1"></ul>
				</div>
				<div title="基础配置" iconCls="icon-tip" selected="true">
					<ul id="tt" class="easyui-tree" data-options="url:'security_data.json'"></ul>
				</div>
				<div title="other" >
				</div>
			</div>
		</div>
		<div region="center" style="overflow: hidden;">
			<div class="easyui-tabs" fit="true" border="false" id="tabs-content">
				<div title="首页" style="padding: 20px; overflow: hidden;">
					<div style="margin-top: 20px;">
						<h3>
							jQuery EasyUI framework help you build your web page easily.
						</h3>
					</div>
				</div>
			</div>
		</div>

		<div id="dialogWindow" closed="true" iconCls="icon-save">
			<div class="easyui-layout" fit="true">
				<div region="center" border="false"
					style="padding: 10px; background: #fff; border: 1px solid #ccc;">
					<iframe id="dialogWindowIframe" name="dialogWindowIframe"
						scrolling="auto" frameborder="0" src=""
						style="margin: 0; padding: 0; width: 100%; height: 100%;"></iframe>
				</div>
				<div region="south" border="false"
					style="text-align: right; height: 30px; line-height: 30px">
					<a class="easyui-linkbutton" iconCls="icon-cancel"
						href="javascript:void(0)" onclick="closeWindow()">关闭</a>
				</div>
			</div>
		</div>
	</body>

</html>